package com.bwie.controller;

import com.bwie.pojo.Tactics;
import com.bwie.service.GoodService;
import com.bwie.util.R;
import com.bwie.vo.GoodVo;
import com.bwie.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @program: day0513-monthlx
 * @ClassName GoodController
 * @description:
 * @author: 段阳
 * @create: 2024-05-14 15:31
 **/
@RestController
@RequestMapping("good")
public class GoodController {
    @Autowired
    private GoodService goodService;

    @PostMapping("/list")
    public R findGoodsList(@RequestBody PageVo pageVo){
        return goodService.findGoodsList(pageVo);
    }


    @PostMapping("/type")
    public R findTypeList(@RequestParam Integer pid){
        return goodService.findTypeList(pid);
    }


    @PostMapping("/uploadPhoto")
    public R uploadPhoto(MultipartFile file) throws IOException {
        return goodService.uploadPhoto(file);
    }

    @PostMapping("/uploadVideo")
    public R uploadVideo(MultipartFile file) throws IOException {
        return goodService.uploadVideo(file);
    }

    @PostMapping("/addNewGood")
    public R addNewGood(@RequestBody GoodVo goodVo){
        return goodService.addNewGood(goodVo);
    }
    @PostMapping("/upGoodRecom")
    public R upGoodRecom(@RequestParam Integer id) {
        return goodService.upGoodRecom(id);
    }

    @PostMapping("/upTacticStatus")
    public R upTacticStatus(@RequestParam Integer id) {
        return goodService.upTacticStatus(id);
    }

    @PostMapping("/addNewTactic")
    public R addNewTactic(@RequestBody Tactics tactics){
        return goodService.addNewTactic(tactics);
    }


    @PostMapping("/typeList")
    public R typeList(){
        return goodService.typeList();
    }

    @PostMapping("/getVCode")
    public R getVCode() throws IOException {
        return goodService.getVCode();
    }

}